<template>
  <div>
    <crumbs
      @goBack="
        () => {
          $router.push({ path: '/workshopPlanList' })
        }
      "
      :superiorMenu="['计划管理', '车间计划']"
      currentMenu="排产详情"
    />

    <div>
      <!-- <div class="wrap">
        <div class="title">基本信息</div>
        <div class="box">
          <div class="boxs" v-for="(item, index) in detailList" :key="index">
            <p class="key">{{item.key}}</p>
            <p class="value">{{item.value}}</p>
          </div>
        </div>
      </div> -->
      <div class="head">
        <div class="box">
          <div class="boxs" v-for="(item, index) in detailList" :key="index">
            <p class="key">{{ item.key }}</p>
            <p class="value" :style="{ color: item.color }">{{ item.value }}</p>
          </div>
        </div>
      </div>

      <div class="wrap" style="height: calc(100vh - 410px); overflow-y: scroll">
        <div class="title">排产明细</div>
        <div style="padding: 20px; text-align: center">
          <j-editable-table
            style="font-size: 14px"
            :ref="editableTable.refKeys"
            :loading="editableTable.loading"
            :columns="editableTable.columns"
            :dataSource="editableTable.dataSource"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import crumbs from '@/components/crumbs.vue'
import JEditableTable from '@/components/jeecg/JEditableTable.vue'
import { getAction } from '@/api/manage'
export default {
  components: { crumbs, JEditableTable },
  data() {
    return {
      editableTable: {
        loading: false,
        refKeys: 'editableTable',
        columns: [
          {
            title: '工序',
            key: 'processName',
          },
          {
            title: '班组',
            key: 'operationTeamIdText',
          },
          {
            title: '生产设备',
            key: 'deviceIdText',
          },
          {
            title: '计划开始时间',
            key: 'planStartTime',
          },
          {
            title: '计划结束时间',
            key: 'planEndTime',
          },
        ],
        dataSource: [],
      },
      detailList: [],
    }
  },
  created() {
    getAction('/planmgt/erpProductScheduling/querySchedulingInfoById', { id: this.$route.query.id }).then((res) => {
      console.log(res, 'detail')
      let e = res.result
      if (res.code === 200) {
        this.detailList = [
          {
            key: '生产订单编号',
            value: e.code || '-',
          },
          {
            key: '生产负责人',
            value: e.chargeUserIdText || '-',
          },
          {
            key: '工艺路线',
            value: e.craftName || '-',
          },
          {
            key: '生产商品编号',
            value: e.goodsCode || '-',
          },
          {
            key: '商品名称',
            value: e.goodsName || '-',
          },
          {
            key: '规格',
            value: e.spec || '-',
          },
          {
            key: '承诺交期',
            value: e.promiseDate || '-',
            color: 'red',
          },
          {
            key: '计划生产数量',
            value: e.planProductNumUnitText || '-',
            color: 'red',
          },
        ]
        this.editableTable.dataSource = e.erpProductSchedulingInfoListVo.map((e) => {
          e.dispatchTxt = '派工到班组'
          return e
        })
      }
    })
  },
  methods: {},
}
</script>
<style lang="less" scoped>
.wrap {
  background: #fff;
  margin-top: 12px;
  .title {
    font-size: 16px;
    font-weight: bold;
    color: #191f25;
    padding: 15px 20px;
    border-bottom: 1px solid #f5f5f5;
  }
}
/deep/.thead {
  background: #fafafa !important;
}
.head {
  width: 102%;
  margin-left: -12px;
  .box {
    background: #fff;
    border-top: 1px solid #f5f5f5;
    display: flex;
    justify-content: start;
    flex-wrap: wrap;
    padding: 20px 20px 0 32px;
    .boxs {
      width: 33.3%;
      margin-bottom: 25px;
      p {
        margin-bottom: 8px;
        font-size: 14px;
      }
      .key {
        color: #444;
      }
      .value {
        color: #888;
      }
    }
  }
}
</style>